<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="t" tagdir="/WEB-INF/tags"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
	<jsp:include page="/WEB-INF/views/title.jsp" />
</title>
<jsp:include page="/WEB-INF/views/head.jsp" />
</head>
<body>
	<jsp:include page="/WEB-INF/views/common/message.jsp"></jsp:include>
	<div class="well bordered-top bordered-sky">
		<div class="mb-3">
			<a href="javascript:void(0);" class="btn btn-default btn-sm mr-2">
				<i class="fa fa-reply"></i>
				返回
			</a>
		</div>
		<form class="form-horizontal" role="form" action="save" method="post">
		<div id="horizontal-form">
			<input type="hidden" name="id" value="${user.id}"/>
			<div class="row">
				<div class="col-sm-12">
					<div class="form-group">
						<label for="userName" class="col-sm-2 control-label no-padding-right">用户名</label>
						<div class="col-sm-4">
							<input type="password" style="opacity:0;position: absolute;"/>
							<input type="password" style="opacity:0;position: absolute;"/>
							<input type="text" class="form-control" name="userName" id="userName" value="${user.userName}" placeholder="用户名">
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-12">
					<div class="form-group">
						<label for="password" class="col-sm-2 control-label no-padding-right">密码</label>
						<div class="col-sm-4">
							<input type="password" class="form-control" id="password" name="password" value="${user.password}" placeholder="密码">
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-12">
					<div class="form-group">
						<label for="roleList" class="col-sm-2 control-label no-padding-right">角色列表</label>
						<div class="col-sm-4">
							<select class="w-100" id="roleList" name="roleIds" multiple="multiple">
								<c:forEach var="role" items="${roleList}">
									<c:choose>
										<c:when test="${userRoles.contains(role)}">
											<option value="${role.id}" selected="selected">${role.name}</option>
										</c:when>
										<c:otherwise>
											<option value="${role.id}">${role.name}</option>
										</c:otherwise>
									</c:choose>
								</c:forEach>
							</select>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-6">
					<div class="form-group">
						<label for="password" class="col-sm-4 control-label no-padding-right">是否激活</label>
						<div class="col-sm-8">
							<label style="position: relative;height: 34px;margin: 0;vertical-align: middle;">
								<input class="checkbox-slider slider-icon colored-palegreen" type="checkbox" <c:if test="${user.active}">checked="checked"</c:if> name="active" value="1"/>
								<span class="text" style="margin-top:6px;"></span>
							</label>
						</div>
					</div>
				</div>
				<div class="col-sm-6">
					<div class="form-group">
						<label class="col-sm-4 control-label no-padding-right">是否锁定</label>
						<div class="col-sm-8">
							<label style="position: relative;height: 34px;margin: 0;vertical-align: middle;">
								<input class="checkbox-slider slider-icon colored-palegreen" type="checkbox" <c:if test="${user.locked}">checked="checked"</c:if> name="locked" value="1"/>
								<span class="text" style="margin-top:6px;"></span>
							</label>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="mb-3">
			<button type="submit" class="btn btn-success btn-sm mr-2">
				<i class="fa fa-save"></i>
				保存
			</button>
		</div>
		</form>
	</div>
	<jsp:include page="/WEB-INF/views/script.jsp" />
	<script src="${ctx}/static/beyond/js/select2/select2.js"></script>
	<script type="text/javascript">
		$(function(){
			$("select").select2({
            placeholder: "选择角色",
            allowClear: true,
            formatNoMatches: function(){
            	return "没有可选项";
            }
        });
		});
	</script>
</body>
</html>
